/*
 * @Author: cl
 * @Description:
 * @Date: 2023-05-15 10:54:37
 * @LastEditTime: 2023-07-05 15:09:53
 * @FilePath: \vue3scaffold\vite.config.ts
 * @LastEditors: chenli chenli@kcwl.com
 */
import vue from "@vitejs/plugin-vue";
import { defineConfig, ConfigEnv, loadEnv } from "vite";
import myAlias from "./vite/alias";
import path from "path";
import { parseEnv } from "./vite/utils";
import setupPlugins  from "./vite/plugins";

// export default defineConfig({
//   plugins: [vue()],
//   resolve: {
//     alias:myalias
//   },
// });

export default ({ command, mode }: ConfigEnv) => {
  const isBuild = command === "build";
  const root = process.cwd();
  const env = parseEnv(loadEnv(mode, root));
  // const env = loadEnv(mode, root);
  return {
    // plugins: [vue()],
    plugins: setupPlugins(isBuild,env),
    resolve: {
      alias: myAlias,
    },
  };
};
